﻿#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    file = FileHandler::getInstance();
    ui->listDir->addItems(file->getFileList());
    qDebug() << file->getFileDir();
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_buttonRead_clicked()
{
    QListWidgetItem *item = ui->listDir->currentItem();
    QString name = item->text();
    QString path = file->getFileDir() + "/" + name;
    qDebug() << name << path;

    QString byte = file->readFile(path);
    JsonReader json(byte);
    int *temp = json.getData();
    file->writeFile(file->getOutDir() + "/" + name, temp, 100000);
}

void Widget::on_buttonOut_clicked()
{

}
